#pragma once
#include "GLBillBoard.h"
#include "GLIcon.h"
#include "GLLine.h"
#include "RenderController.h"
#include "common.h"
struct GLRenderComp
{
public:
	GLIcon*		 mIcon		= nullptr;
	GLLine*		 mLine		= nullptr;
	GLBillBoard* mBillBoard = nullptr;
	uint32_t	 mIndex		= 0;

public:
	GLRenderComp(uint32_t index)
		: mIndex(index)
	{
		mIcon	   = new GLIcon();
		mLine	   = new GLLine();
		mBillBoard = new GLBillBoard();
		mBillBoard->setGeometryChangedCallback([this]() {
			mLine->setStop(mBillBoard->pos());
			gController->lineRender()->updateDataByIndex(mIndex);
			gController->billBoardRender()->updateData();
			gController->renderRequest();
		});
		mBillBoard->setIsExpandChangedCallback(
			[this]()
			{
				gController->billBoardRender()->updateData();
				gController->renderRequest();
			});
		mBillBoard->setIsSelectedChangedCallback(
			[this]()
			{
				gController->billBoardRender()->updateData();
				gController->renderRequest();
			});
	}
	~GLRenderComp()
	{
		safeDelete(mIcon);
		safeDelete(mLine);
		safeDelete(mBillBoard);
	}
};
